package com.pda.xinma.presenter;

import com.pda.xinma.bean.DeliveryInfoBean;
import com.pda.xinma.contract.MachineCallDetialContract;
import com.pda.xinma.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import io.reactivex.functions.Consumer;

public class MachineCallDetialPresenter extends BasePresenter<MachineCallDetialContract.View> implements MachineCallDetialContract.Presenter {
    @Override
    public void getDeliveryInfoByFlowId(String flowId) {
        NetUtils.geApi().getDeliveryInfoByFlowId(flowId)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<DeliveryInfoBean>>() {
                    @Override
                    public void accept(BaseAppEntity<DeliveryInfoBean> deliveryInfoBeanBaseAppEntity) throws Exception {
                        getView().setData(deliveryInfoBeanBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
